package com.itheima.service.impl;

import com.itheima.mapper.SetmealMapper;
import com.itheima.service.SetmealService;
import com.itheima.common.constant.MessageConstant;
import com.itheima.common.exception.DataNotFoundException;
import com.itheima.pojo.Setmeal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class SetmealServiceimpl implements SetmealService {
    @Autowired
    SetmealMapper setmealMapper;
    @Override
    public ArrayList<Setmeal> getAll() {
return setmealMapper.getAll();
    }

    @Override
    public Setmeal finById(Integer id) {
        Setmeal setmeal = setmealMapper.selectById(id);
        if (setmeal == null) {
            throw new DataNotFoundException(MessageConstant.QUERY_SETMEAL_FAIL);
        }
        return setmeal;
    }

}
